home *** CD-ROM | disk | FTP | other *** search
/ Java Certification Exam Guide / McGrawwHill-JavaCertificationExamGuide.iso / pc / Web Links and Code / ans / chap6 / exer0602 / Apple.java
Encoding:
Java Source  |  1997-04-19  |  471 b   |  15 lines

  1. class Fruit { }
  2. class Apple extends Fruit {
  3.    public static void main(String[] args) {
  4.       Apple[] a = new Apple[1];
  5.       Fruit[] f = new Fruit[1];
  6.       Object[] o = new Object[1];
  7.       if (a instanceof Fruit[])
  8.          System.out.println("a inherits from Fruit[]");
  9.       if (f instanceof Object[])
  10.          System.out.println("f inherits from Object[]");
  11.       if (o instanceof Object)
  12.          System.out.println("o inherits from Object");
  13.    }
  14. }
  15.